package JiHeDemo;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

public class JiHe2 {
	public static void main(String[] args) {
		Collection collection = new ArrayList();
		Student s1 = new Student("1", 1);
		Student s2 = new Student("2", 2);
		Student s3 = new Student("3", 3);
		collection.add(s1);
		collection.add(s2);
		collection.add(s3);
		collection.add(s3);
		System.out.println("元素个数" + collection.size());
		System.out.println(collection);
		System.out.println("===for====");
		for (Object o : collection) {
			System.out.println(o.toString());
		}
		System.out.println("使用迭代器");
		Iterator it = collection.iterator();
		while (it.hasNext()) {
			System.out.println(it.next().toString());
		}

	}
}


